home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / ada.vim < prev    next >
Encoding:
Text File  |  2001-05-11  |  10.0 KB  |  275 lines

  1. " Vim syntax file
  2. " Language:    Ada (95)
  3. " Maintainer:    David A. Wheeler <dwheeler@dwheeler.com>
  4. " URL: http://www.dwheeler.com/vim
  5. " Last Change:    2001 May 10
  6.  
  7. " Former Maintainer:    Simon Bradley <simon.bradley@pitechnology.com>
  8. "            (was <sib93@aber.ac.uk>)
  9. " The formal spec of Ada95 (ARM) is the "Ada95 Reference Manual";
  10. " a copy is available at "http://www.adahome.com/rm95/". For more Ada95 info,
  11. " see http://www.gnuada.org and http://www.adapower.com.
  12.  
  13. " This vim syntax file works on vim 5.6, 5.7, 5.8 and 6.x.
  14. " It implements Bram Moolenaar's April 25, 2001 recommendations to make
  15. " the syntax file maximally portable across different versions of vim.
  16. " If vim 6.0+ is available,
  17. " this syntax file takes advantage of the vim 6.0 advanced pattern-matching
  18. " functions to avoid highlighting uninteresting leading spaces in
  19. " some expressions containing "with" and "use".
  20.  
  21. " For version 5.x: Clear all syntax items
  22. " For version 6.x: Quit when a syntax file was already loaded
  23. if version < 600
  24.  syntax clear
  25. elseif exists("b:current_syntax")
  26.  finish
  27. endif
  28.  
  29. " Ada is entirely case-insensitive.
  30. syn case ignore
  31.  
  32. " We don't need to look backwards to highlight correctly;
  33. " this speeds things up greatly.
  34. syn sync minlines=1 maxlines=1
  35.  
  36. " Highlighting commands.  There are 69 reserved words in total in Ada95.
  37. " Some keywords are used in more than one way. For example:
  38. " 1. "end" is a general keyword, but "end if" ends a Conditional.
  39. " 2. "then" is a conditional, but "and then" is an operator.
  40.  
  41.  
  42. " Standard Exceptions (including I/O).
  43. " We'll highlight the standard exceptions, similar to vim's Python mode.
  44. " It's possible to redefine the standard exceptions as something else,
  45. " but doing so is very bad practice, so simply highlighting them makes sense.
  46. syn keyword adaException Constraint_Error Program_Error Storage_Error
  47. syn keyword adaException Tasking_Error
  48. syn keyword adaException Status_Error Mode_Error Name_Error Use_Error
  49. syn keyword adaException Device_Error End_Error Data_Error Layout_Error
  50. syn keyword adaException Length_Error Pattern_Error Index_Error
  51. syn keyword adaException Translation_Error
  52. syn keyword adaException Time_Error Argument_Error
  53. syn keyword adaException Tag_Error
  54. syn keyword adaException Picture_Error
  55. " Interfaces
  56. syn keyword adaException Terminator_Error Conversion_Error
  57. syn keyword adaException Pointer_Error Dereference_Error Update_Error
  58. " This isn't in the Ada spec, but a GNAT extension.
  59. syn keyword adaException Assert_Failure
  60. " We don't list ALL exceptions defined in particular compilers (e.g., GNAT),
  61. " because it's quite reasonable to define those phrases as non-exceptions.
  62.  
  63.  
  64. " We don't normally highlight types in package Standard
  65. " (Integer, Character, Float, etc.).  I don't think it looks good
  66. " with the other type keywords, and many Ada programs define
  67. " so many of their own types that it looks inconsistent.
  68. " However, if you want this highlighting, turn on "ada_standard_types".
  69. " For package Standard's definition, see ARM section A.1.
  70.  
  71. if exists("ada_standard_types")
  72.   syn keyword adaBuiltinType    Boolean Integer Natural Positive Float
  73.   syn keyword adaBuiltinType    Character Wide_Character
  74.   syn keyword adaBuiltinType    String Wide_String
  75.   syn keyword adaBuiltinType    Duration
  76.   " These aren't listed in ARM section A.1's code, but they're noted as
  77.   " options in ARM sections 3.5.4 and 3.5.7:
  78.   syn keyword adaBuiltinType    Short_Integer Short_Short_Integer
  79.   syn keyword adaBuiltinType    Long_Integer Long_Long_Integer
  80.   syn keyword adaBuiltinType    Short_Float Short_Short_Float
  81.   syn keyword adaBuiltinType    Long_Float Long_Long_Float
  82. endif
  83.  
  84. " There are MANY other predefined types; they've not been added, because
  85. " determining when they're a type requires context in general.
  86. " One potential addition would be Unbounded_String.
  87.  
  88.  
  89. syn keyword adaLabel        others
  90.  
  91. syn keyword adaOperator        abs mod not rem xor
  92. syn match adaOperator        "\<and\>"
  93. syn match adaOperator        "\<and\s\+then\>"
  94. syn match adaOperator        "\<or\>"
  95. syn match adaOperator        "\<or\s\+else\>"
  96. syn match adaOperator        "[-+*/<>&]"
  97. syn keyword adaOperator        **
  98. syn match adaOperator        "[/<>]="
  99. syn keyword adaOperator        =>
  100. syn match adaOperator        "\.\."
  101. syn match adaOperator        "="
  102.  
  103. " We won't map "adaAssignment" by default, but we need to map ":=" to
  104. " something or the "=" inside it will be mislabelled as an operator.
  105. " Note that in Ada, assignment (:=) is not considered an operator.
  106. syn match adaAssignment        ":="
  107.  
  108. " Handle the box, <>, specially:
  109. syn keyword adaSpecial    <>
  110.  
  111. " Numbers, including floating point, exponents, and alternate bases.
  112. syn match   adaNumber        "\<\d[0-9_]*\(\.\d[0-9_]*\)\=\([Ee][+-]\=\d[0-9_]*\)\=\>"
  113. syn match   adaNumber        "\<\d\d\=#\x[0-9A-Fa-f_]*\(\.\x[0-9A-Fa-f_]*\)\=#\([Ee][+-]\=\d[0-9_]*\)\="
  114.  
  115. " Identify leading numeric signs. In "A-5" the "-" is an operator,
  116. " but in "A:=-5" the "-" is a sign. This handles "A3+-5" (etc.) correctly.
  117. " This assumes that if you put a don't put a space after +/- when it's used
  118. " as an operator, you won't put a space before it either -- which is true
  119. " in code I've seen.
  120. syn match adaSign "[[:space:]<>=(,|:;&*/+-][+-]\d"lc=1,hs=s+1,he=e-1,me=e-1
  121.  
  122. " Labels for the goto statement.
  123. syn region  adaLabel        start="<<"  end=">>"
  124.  
  125. " Boolean Constants.
  126. syn keyword adaBoolean    true false
  127.  
  128. " Warn people who try to use C/C++ notation erroneously:
  129. syn match adaError "//"
  130. syn match adaError "/\*"
  131. syn match adaError "=="
  132.  
  133.  
  134. if exists("ada_space_errors")
  135.   if !exists("ada_no_trail_space_error")
  136.     syn match   adaSpaceError     excludenl "\s\+$"
  137.   endif
  138.   if !exists("ada_no_tab_space_error")
  139.     syn match   adaSpaceError     " \+\t"me=e-1
  140.   endif
  141. endif
  142.  
  143. " Unless special ("end loop", "end if", etc.), "end" is an ordinary keyword.
  144. syn match adaKeyword        "\<end\>"
  145.  
  146. syn keyword adaPreproc        pragma
  147.  
  148. syn keyword adaRepeat        exit for loop reverse while
  149. syn match adaRepeat        "\<end\s\+loop\>"
  150.  
  151. syn keyword adaStatement    accept delay goto raise requeue return
  152. syn keyword adaStatement    terminate
  153. syn match adaStatement    "\<abort\>"
  154.  
  155. " 'record' usually starts a structure, but "with null record;" does not.
  156. syn match adaStructure    "\<record\>"
  157. syn match adaKeyword    "\<record;"me=e-1
  158.  
  159. syn keyword adaStorageClass    abstract access aliased array at constant delta
  160. syn keyword adaStorageClass    digits limited of private range tagged
  161. syn keyword adaTypedef        subtype type
  162.  
  163. " Conditionals. "abort" after "then" is a conditional of its own.
  164. syn match adaConditional    "\<then\>"
  165. syn match adaConditional    "\<then\s\+abort\>"
  166. syn match adaConditional    "\<else\>"
  167. syn match adaConditional    "\<end\s\+if\>"
  168. syn match adaConditional    "\<end\s\+case\>"
  169. syn match adaConditional    "\<end\s\+select\>"
  170. syn keyword adaConditional    if case select
  171. syn keyword adaConditional    elsif when
  172.  
  173. syn keyword adaKeyword        all do exception in is new null out
  174. syn keyword adaKeyword        separate until
  175.  
  176. " These keywords begin various constructs, and you _might_ want to
  177. " highlight them differently.
  178. syn keyword adaBegin        begin body declare entry function generic
  179. syn keyword adaBegin        package procedure protected renames task
  180.  
  181.  
  182. if exists("ada_withuse_ordinary")
  183. " Don't be fancy. Display "with" and "use" as ordinary keywords in all cases.
  184.  syn keyword adaKeyword        with use
  185. else
  186.  " Highlight "with" and "use" clauses like C's "#include" when they're used
  187.  " to reference other compilation units; otherwise they're ordinary keywords.
  188.  " If we have vim 6.0 or later, we'll use its advanced pattern-matching
  189.  " capabilities so that we won't match leading spaces.
  190.  syn match adaKeyword    "\<with\>"
  191.  syn match adaKeyword    "\<use\>"
  192.  if version < 600
  193.   syn match adaBeginWith "^\s*\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
  194.   syn match adaSemiWith    ";\s*\(\(with\(\s\+type\)\=\)\|\(use\)\)\>"lc=1 contains=adaInc
  195.  else
  196.   syn match adaBeginWith "^\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
  197.   syn match adaSemiWith    ";\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
  198.  endif
  199.  syn match adaInc    "\<with\>" contained contains=NONE
  200.  syn match adaInc    "\<with\s\+type\>" contained contains=NONE
  201.  syn match adaInc    "\<use\>" contained contains=NONE
  202.  " Recognize "with null record" as a keyword (even the "record").
  203.  syn match adaKeyword    "\<with\s\+null\s\+record\>"
  204.  " Consider generic formal parameters of subprograms and packages as keywords.
  205.  if version < 600
  206.   syn match adaKeyword    ";\s*with\s\+\(function\|procedure\|package\)\>"
  207.   syn match adaKeyword    "^\s*with\s\+\(function\|procedure\|package\)\>"
  208.  else
  209.   syn match adaKeyword    ";\s*\zswith\s\+\(function\|procedure\|package\)\>"
  210.   syn match adaKeyword    "^\s*\zswith\s\+\(function\|procedure\|package\)\>"
  211.  endif
  212. endif
  213.  
  214.  
  215. " String and character constants.
  216. syn region  adaString        start=+"+  skip=+""+  end=+"+
  217. syn match   adaCharacter    "'.'"
  218.  
  219. " Todo (only highlighted in comments)
  220. syn keyword adaTodo contained    TODO FIXME XXX
  221.  
  222. " Comments.
  223. syn region  adaComment    oneline contains=adaTodo start="--"  end="$"
  224.  
  225.  
  226.  
  227. " Define the default highlighting.
  228. " For version 5.7 and earlier: only when not done already
  229. " For version 5.8 and later: only when an item doesn't have highlighting yet
  230. if version >= 508 || !exists("did_ada_syn_inits")
  231.   if version < 508
  232.     let did_ada_syn_inits = 1
  233.     command -nargs=+ HiLink hi link <args>
  234.   else
  235.     command -nargs=+ HiLink hi def link <args>
  236.   endif
  237.  
  238.   " The default methods for highlighting. Can be overridden later.
  239.   HiLink adaCharacter    Character
  240.   HiLink adaComment    Comment
  241.   HiLink adaConditional    Conditional
  242.   HiLink adaKeyword    Keyword
  243.   HiLink adaLabel    Label
  244.   HiLink adaNumber    Number
  245.   HiLink adaSign    Number
  246.   HiLink adaOperator    Operator
  247.   HiLink adaPreproc    PreProc
  248.   HiLink adaRepeat    Repeat
  249.   HiLink adaSpecial    Special
  250.   HiLink adaStatement    Statement
  251.   HiLink adaString    String
  252.   HiLink adaStructure    Structure
  253.   HiLink adaTodo    Todo
  254.   HiLink adaType    Type
  255.   HiLink adaTypedef    Typedef
  256.   HiLink adaStorageClass    StorageClass
  257.   HiLink adaBoolean    Boolean
  258.   HiLink adaException    Exception
  259.   HiLink adaInc    Include
  260.   HiLink adaError    Error
  261.   HiLink adaSpaceError    Error
  262.   HiLink adaBuiltinType Type
  263.   if exists("ada_begin_preproc")
  264.    HiLink adaBegin    PreProc
  265.   else
  266.    HiLink adaBegin    Keyword
  267.   endif
  268.  
  269.   delcommand HiLink
  270. endif
  271.  
  272. let b:current_syntax = "ada"
  273.  
  274. " vim: ts=8
  275.